Generate the document's ID on demand instead of the class constructor #2814
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solves #2813.
Referring to #2813, subsequent
<Document />
renders produces a PDF file with non-deterministic/ID
even though thecreationDate
andmodificationDate
props were set. If I managed to understand correctly, the ID is generated when thePDFDocument
class was instantiated. However, some of the.info
object's fields were updated from outside the class instance during the rendering process:However, the ID was generated based on the
.info
in the constructor and was not updated after the.info
object was updated. This means that the ID is generated with the defaultCreationDate
which is the current time.This PR changes the behaviour so that the ID is not generated in the constructor but rather only when it is needed. Therefore, the modifications in the
.info
object should already be made at that point.